/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sda.levelup.ciphers;

import java.util.Scanner;

/**
 *
 * @author Дима
 */
public class Ciphers
{

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args)
    {
        System.out.println("Type \"1\" for Caesar method or \"2\" for Vigenere method");

        Scanner sc = new Scanner(System.in);
        int type = Integer.parseInt(sc.nextLine());

        System.out.println("Type \"1\" to encrypt or \"2\" to decrypt");
        int ed = Integer.parseInt(sc.nextLine());
        System.out.println("Type text:");
        String text = sc.nextLine();
        System.out.println("Type key:");
        String key = sc.nextLine();
        Scrambler scrambler = new Scrambler();

        if (type == 1 && ed == 1)
        {
            System.out.println("Encrypted text:");
            System.out.println(scrambler.encryptText(text, key, Scrambler.CipherType.CAESAR));
        }
        else if (type == 1 && ed == 2)
        {
            System.out.println("Decrypted text:");
            System.out.println(scrambler.decryptText(text, key, Scrambler.CipherType.CAESAR));
        }
        else if (type == 2 && ed == 1)
        {
            System.out.println("Encrypted text:");
            System.out.println(scrambler.encryptText(text, key, Scrambler.CipherType.VIGENERE));
        }
        else if (type == 2 && ed == 2)
        {
            System.out.println("Decrypted text:");
            System.out.println(scrambler.decryptText(text, key, Scrambler.CipherType.VIGENERE));
        }

    }
}
